﻿<businessLogic1:DialogBase x:Class="PDM.Client.Windows.EditDocumentWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                           xmlns:businessLogic1="clr-namespace:PDM.BusinessLogic"
                           xmlns:controls="clr-namespace:PDM.Client.Controls"
                           Title="Edit document" Height="460" Width="700">
    <Grid Margin="5, 0, 5, 0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="10" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="10" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <Label Grid.Row="0" Grid.Column="0" Content="File path:"></Label>
        <Label Grid.Row="0" Grid.Column="2" Content="{Binding Document.FilePath, Mode=OneTime}"></Label>

        <Label Grid.Row="1" Grid.Column="0" Content="Date:"></Label>
        <StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal" >
            <DatePicker  SelectedDate="{Binding Document.Date, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Width="110"></DatePicker>
            <Button Margin="5, 0, 0, 0" Click="TodayDateButton_OnClick" ToolTip="Today">
                <Image Source="{StaticResource TodayDateIcon}" Height="20" />
            </Button>
            <Button Margin="5, 0, 0, 0" Click="FileDateButton_OnClick" ToolTip="File date">
                <Image Source="{StaticResource FileDateIcon}" Height="20" />
            </Button>
        </StackPanel>
        

        <Label Grid.Row="3" Grid.Column="0" Content="Description:"></Label>
        <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding Document.Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>

        <Label Grid.Row="4" Grid.Column="0" Content="Project:"></Label>        
        <controls:AutoCompleteTextBox Grid.Row="4" Grid.Column="2" x:Name="AutoCompleteTextBox" Threshold="1"></controls:AutoCompleteTextBox>

        <Label Grid.Row="5" Grid.Column="0" Content="Owner:"></Label>
        <TextBox Grid.Row="5" Grid.Column="2" Text="{Binding Document.Owner, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>

        <Label Grid.Row="7" Grid.Column="0" Content="Keywords:"></Label>
        <StackPanel Grid.Row="7" Grid.Column="2" Orientation="Vertical">  
            <StackPanel Orientation="Horizontal">
                <TextBox x:Name="KeywordTextBox" Text="{Binding Keyword, UpdateSourceTrigger=PropertyChanged}" Width="250"  KeyUp="KeywordTextBox_OnKeyUp"></TextBox>
                <Button Content="Add" Command="{Binding AddKeywordCommand}" Margin="10, 0, 0, 0" Width="{StaticResource DefaultButtonWidth}"></Button>
                <Button Content="Remove" Command="{Binding RemoveKeywordCommand}" Margin="10, 0, 0, 0" Width="{StaticResource DefaultButtonWidth}"></Button>
            </StackPanel>            
            <ListBox IsSynchronizedWithCurrentItem="True" VirtualizingStackPanel.IsVirtualizing="True"
                             ItemsSource="{Binding Path=Document.Keywords, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                              SelectionMode="Single" VerticalContentAlignment="Stretch"
                     SelectedItem="{Binding SelectedKeyword, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
                     Height="200" Margin="0, 10, 0, 0">
            </ListBox>

        </StackPanel>

        <StackPanel Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="_Save" Width="{StaticResource DefaultButtonWidth}" Margin="0, 0, 0, 0" HorizontalAlignment="Right" Click="SaveButton_Click" />
            <Button Content="Cancel" Width="{StaticResource DefaultButtonWidth}" Margin="10, 0, 10, 0" HorizontalAlignment="Right" Click="CancelButton_Click" />
        </StackPanel>
    </Grid>
</businessLogic1:DialogBase>
